<?php include TMPL_PATH . 'public/header.phtml'; ?>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/jscal2.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/border-radius.css"/>
<link rel="stylesheet" type="text/css" href="/statics/js/calendar/win2k.css"/>
<script type="text/javascript" src="/statics/js/calendar/calendar.js"></script>
<script type="text/javascript" src="/statics/js/calendar/lang/zh-cn.js"></script>
<div class="subnav">
    <div class="content-menu ib-a blue line-x" style="overflow:hidden;">
        <div style="float:left;margin-right:50px;">
            <a href='javascript:;' class="on"><em>用料记录</em></a>
        </div>
        <form name="searchform" action="<?php echo U('suppliers/inventory');?>"  method="post">
        <div style="float:left;">
            用料时间: &nbsp;
            <input class="input-text" name="start_time" type="text" id="start_time" size="22" value='<?php echo $start_time; ?>'/>-
            <input class="input-text" name="end_time" type="text" id="end_time" size="22" value='<?php echo $end_time; ?>'/>
            <script type="text/javascript">
                Calendar.setup({
                    weekNumbers: false,
                    inputField: "start_time",
                    trigger: "start_time",
                    dateFormat: "%Y-%m-%d",
                    showTime: false,
                    minuteStep: 1,
                    onSelect: function () {
                        this.hide();
                    }
                });
            </script>
            <script type="text/javascript">
                Calendar.setup({
                    weekNumbers: false,
                    inputField: "end_time",
                    trigger: "end_time",
                    dateFormat: "%Y-%m-%d",
                    showTime: false,
                    minuteStep: 1,
                    onSelect: function () {
                        this.hide();
                    }
                });
            </script>
            <input type="hidden" name="type" value="<?php echo $type; ?>">
            <input type="hidden" name="tid" value="<?php echo $tid; ?>">
            <input type="submit" value="搜索" class="button" name="time_search">
        </div>
        </form>
        <div style="float:left;margin-right:50px;">
            <a href="<?php echo U('suppliers/inventory',array('start_time'=>$start_time,'end_time'=>$end_time,'type'=>$type,'tid'=>$tid,'action'=>'export'));?>" class="on" ><em>导出</em></a>
        </div>

    </div>

</div>
<div class="pad_10">
    <div class="table-list">
        <?php if ($type < 2 ): ?>
            <?php if($tid):?>
            <div class="subnav">
                <?php if ($type == 0){ ?>
                    <a href="<?php echo U('suppliers/inventory_add', array('tid' => $suppliers['suppliers_id'], 'type' => 0)); ?>">新增记录</a> |
                    面料编号：<?php echo $suppliers['suppliers_name']; ?>
                <?php }elseif($type == 1){ ?>
                    <a href="<?php echo U('suppliers/inventory_add', array('tid' => $suppliers['lining_id'], 'type' => 1)); ?>">新增记录</a> |
                    里布编号：<?php echo $suppliers['suppliers_name']; ?>
                <?php } ?>

                总用料：<?php echo $suppliers['decreaseAmount']; ?>米
                结余：<?php echo $suppliers['increaseAmount'] - $suppliers['decreaseAmount']; ?>米
            </div>
            <?php endif; ?>
            <table width="100%" cellspacing="0">
                <thead>
                <tr>
                    <th width="8%" align="center">面料编号</th>
                    <th width="8%" align="center">订单号</th>
                    <th width="5%" align="center">产品ID</th>
                    <th width="8%" align="center">用料(米)</th>
                    <th width="8%" align="center">增加(米)</th>
                    <th width="8%" align="center">结余(米)</th>
                    <th width="8%" align="center">下单时间</th>
                    <th width="8%" align="center">用料时间</th>
                    <th width="50%">备注</th>
                </tr>
                </thead>
                <tbody>
                <?php
                if (isset($inventoryList) && $inventoryList):
                    foreach ($inventoryList as $v):
                        ?>
                        <tr>
                            <td align="left"><?php echo $v['suppliers_name'] ?></td>
                            <td align="center"><?php if ($v['order_sn']) echo $v['order_sn'] . '-' . $v['order_item_id']; ?></td>
                            <td align="center"><?php echo $v['pid'] > 0 ? $v['pid'] : ''; ?></td>
                            <td align="center"><?php echo $v['change'] == 0 ? $v['amount'] : 0; ?></td>
                            <td align="center"><?php echo $v['change'] == 1 ? $v['amount'] : 0; ?></td>
                            <td align="center"><?php echo $v['change'] == 0 ? $v['before'] - $v['amount'] : $v['before'] + $v['amount']; ?></td>
                            <td align="center"><?php echo $v['orderTime'] > 0 ? date('Y-m-d H:i:s', $v['orderTime']) : ''; ?></td>
                            <td align="center"><?php echo date('Y-m-d H:i:s', $v['recordTime']); ?></td>
                            <td align="left"><?php echo $v['remark'] ?></td>
                        </tr>
                        <?php
                    endforeach;
                endif;
                ?>
                </tbody>
            </table>
        <?php elseif ($type == 2): ?>
            <div class="subnav">配件id：<?php echo $product_info['id']; ?>
                总用料：<?php echo $product_info['decreaseAmount']; ?>件
                结余：<?php echo $product_info['increaseAmount'] - $product_info['decreaseAmount']; ?>件
            </div>
            <table width="100%" cellspacing="0">
                <thead>
                <tr>
                    <th width="10%" align="center">订单号</th>
                    <th width="10%" align="center">用料（件）</th>
                    <th width="8%" align="center">增加(件)</th>
                    <th width="10%" align="center">结余（件）</th>
                    <th width="10%" align="center">下单时间</th>
                    <th width="10%" align="center">用料时间</th>
                    <th width="40%">备注</th>
                </tr>
                </thead>
                <tbody>
                <?php
                if (isset($inventoryList) && $inventoryList):
                    foreach ($inventoryList as $v):
                        ?>
                        <tr>
                            <td align="center"><?php echo $v['order_sn'] ?></td>
                            <td align="center"><?php echo $v['change'] == 0 ? $v['amount'] : 0; ?></td>
                            <td align="center"><?php echo $v['change'] == 1 ? $v['amount'] : 0; ?></td>
                            <td align="center"><?php echo $v['change'] == 0 ? $v['before'] - $v['amount'] : $v['before'] + $v['amount']; ?></td>
                            <td align="center"><?php echo $v['orderTime'] > 0 ? date('Y-m-d H:i:s', $v['orderTime']) : ''; ?></td>
                            <td align="center"><?php echo date('Y-m-d H:i:s', $v['recordTime']); ?></td>
                            <td align="left"><?php echo $v['remark'] ?></td>
                        </tr>
                        <?php
                    endforeach;
                endif;
                ?>
                </tbody>
            </table>
        <?php endif; ?>
        <div id="pages"><?php echo $pageShow; ?></div>
    </div>
</div>
</body>
</html>
